<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    .number{
        width: 20%;
        float: left;
    }
    select,
    #deng{
        float: left;
        width: 10%;
    }
    #deng:hover,
    #a{
        cursor: pointer;
    }
    #result{
        float: left;
        width: 25%;
    }
    .time div{
        float: left;
    }
    </style>
</head>
<body>
    <div class="row">
        <input type="text" class="number">
        <select name="" id="operation">
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
        </select>
        <input type="text" class="number">
        
        <input type="button" id="deng" value="计算">
        <input type="text" id="result" >
    </div>
</br></br>
    <div id="a">链接http://wengdo.com</div>
    
</br></br>


<div class="time">
    <div id="shi"></div>
    <div id="fen"></div>
    <div id="miao"></div>
</div>
</br></br>


<a href="./form.html">表单</a>

</body>
</html>
<script>
document.write("</br>")
//1.使用字符串对象将字符串 “马小腾，马小腾”  马小腾替换成huge
var str1="马小腾，马小腾"
document.write(str1.replace(/马小腾/g,"huge"))



//2. 声明一个函数，用来识别当前页面所在的浏览器是什么浏览器。
//如果是IE6、IE7，那么就让当前页面跳转到 	http://www.baidu.com/s?wd=谷歌浏览器
/* navigator.userAgent;
console.log(navigator.userAgent)
function browser(){
    if(navigator.userAgent.search(/Chrome/)!=-1){
        alert("你用的是谷歌浏览器");
        
    }
    if(navigator.userAgent.search(/Firefox/)!=-1){
        alert("你用的是火狐浏览器");
        
    }
    if(navigator.userAgent.search(/Trident\/7.0/)!=-1){
        alert("你用的是IE7.0");
        location.href= "http://www.baidu.com/s?wd=谷歌浏览器";
    }
    if(navigator.userAgent.search(/Trident\/6.0/)!=-1){
        alert("你用的是IE6.0");
        location.href= "http://www.baidu.com/s?wd=谷歌浏览器";
    }
    
    
}
browser();

 */


//3. 声明一个函数，实现两个文本输入框内容的加减乘除运算。

/* 
var number=document.querySelectorAll(".number");
var operation=document.querySelector("#operation");
var deng=document.querySelector("#deng");
var result=document.querySelector("#result"); */

var number=document.getElementsByClassName("number");
var operation=document.getElementById("operation");
var deng=document.getElementById("deng");
var result=document.getElementById("result"); 



deng.onclick=function(){
    
    
    if(number[0].value.match(/((-?)\d+(\.\d+)?)/g)==null || number[1].value.match(/((-?)\d+(\.\d+)?)/g)==null || number[0].value.length==0 || number[1].value.length==0){
        alert("请输入正确的数字");
    }
    
    if(operation.value=="+"){
        result.value=Number(number[0].value)+Number(number[1].value)
    }
    if(operation.value=="-"){
        result.value=Number(number[0].value)-Number(number[1].value)
    }
    if(operation.value=="*"){
        result.value=Number(number[0].value)*Number(number[1].value)
    }
    if(operation.value=="/"){
        result.value=Number(number[0].value)/Number(number[1].value)
    }
}


//4. 实现点击链接3秒后跳转到http://wengdo.com

a.onclick=function(){
    var T=setTimeout(function(){
        location.href="http://wengdo.com";
    },3000);
    

}


//5. 声明一个函数，获取当前时间, 找两个项目，在头部输出动态的时钟


var T1=window.setInterval(function(){
    var shi=document.getElementById("shi");
    var fen=document.getElementById("fen");
    var miao=document.getElementById("miao");

    var date=new Date();
    var hour=date.getHours();
    var minute=date.getMinutes();
    var second=date.getSeconds();

    shi.innerHTML=hour+":";
    fen.innerHTML=minute+":";
    miao.innerHTML=second;
    if(hour<=9){
        shi.innerHTML="0"+hour+":";
    }
    if(minute<10){
        fen.innerHTML="0"+minute+":";
    }
    if(second<10){
        miao.innerHTML="0"+second;
    }

},1000)


//6. 使用bootstrap写课件里面的表单，给表单做js单条和全部验证




</script>